<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>$课堂练习$</title>
    <style>
        div {
            width: 200px;
            height: 450px;
            border: 1px solid red;
        }
    </style>
</head>
<body>
<input type="button" value="变色" id="btn">
<div id="dv">
    <span>这是span</span>
    <p>这是p</p>
    <span>这是span</span>
    <p>这是p</p>
    <span>这是span</span>
    <a href="http://www.qq.com">QQ</a>
</div>
<script src="common.js"></script>
<script>
    my$("btn").onclick = function () {
        var dvobj = my$("dv");
        var nodes = dvobj.childNodes;
        for (var i = 0; i < nodes.length; i++) {
            if (nodes[i].nodeType == 1 && nodes[i].nodeName == "P") {
                nodes[i].style.backgroundColor = "red";
            }
        }
    }
</script>
</body>
</html>